<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        li {
            list-style: none;
        }
        
        ul {
            border: 1px solid red;
            width: 50%;
            height: 200px;
            margin: 100px auto;
            display: flex;
            justify-content: space-between;
        }
        
        li {
            width: 24%;
            border: 1px solid red;
            text-align: center;
            line-height: 200px;
        }
    </style>
</head>

<body>
    <ul>
        <li>商品1</li>
        <li>商品2</li>
        <li>商品3</li>
        <li>商品4</li>
    </ul>
</body>

</html>
<script src="jQuery.js"></script>
<script>
    for (let i = 0; i < $("li").length; i++) {
        $("li").click(function() {
            location.href = "DetailPage.html?goodsId=" + $(this).index();
        });
    }
</script>